//
//  MCRechargeHeaderView.m
//  TLYL
//
//  Created by MC on 2017/6/13.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCRechargeHeaderView.h"
#import "UIView+MCParentController.h"
@interface MCRechargeHeaderView ()

/*
 * 背景
 */
@property (nonatomic,strong)UIImageView * backImgV;
/*
 * 充值
 */
@property (nonatomic,strong)UILabel *rechargeLab;

/*
 * 账户金额
 */
@property (nonatomic,strong)UILabel *moneyLab;

/*
 * 账户余额
 */
@property (nonatomic,strong)UILabel *balanceLab;

/*
 * 返回按钮
 */
@property (nonatomic,strong)UIButton *backBtn;
@end

@implementation MCRechargeHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor=RGB(74, 166, 235);
    
    _backImgV=[[UIImageView alloc]init];
    [self addSubview:_backImgV];
    _backImgV.frame=CGRectMake(0, 0, G_SCREENWIDTH, 164);
    _backImgV.image=[UIImage imageNamed:@"MCRechargeBack"];

   

    _rechargeLab = [[UILabel alloc]init];
    _rechargeLab.layer.cornerRadius=5;
    _rechargeLab.backgroundColor = [UIColor clearColor];
    _rechargeLab.layer.masksToBounds = YES;
    _rechargeLab.font = [UIFont systemFontOfSize:15];
    _rechargeLab.numberOfLines=1;
    _rechargeLab.text = @"充值";
    _rechargeLab.textColor=[UIColor whiteColor];
    _rechargeLab.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_rechargeLab];

    _moneyLab = [[UILabel alloc]init];
    _moneyLab.layer.cornerRadius=5;
    _moneyLab.backgroundColor = [UIColor clearColor];
    _moneyLab.layer.masksToBounds = YES;
    _moneyLab.textColor=[UIColor whiteColor];
    _moneyLab.font = [UIFont boldSystemFontOfSize:24];
    _moneyLab.numberOfLines=1;
    _moneyLab.text = @"99,999,999.00";
    _moneyLab.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_moneyLab];
    
    _balanceLab = [[UILabel alloc]init];
    _balanceLab.layer.cornerRadius=5;
    _balanceLab.textColor=[UIColor whiteColor];
    _balanceLab.backgroundColor = [UIColor clearColor];
    _balanceLab.layer.masksToBounds = YES;
    _balanceLab.font = [UIFont boldSystemFontOfSize:12];
    _balanceLab.numberOfLines=1;
    _balanceLab.text = @"账户余额(元)";
    _balanceLab.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_balanceLab];
    
    [self layOutConstraints];
    
    _backBtn = [[UIButton alloc]init];
    [_backBtn setImage:[UIImage imageNamed:@"图层-6"] forState:UIControlStateNormal];
    _backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    _backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [self addSubview:_backBtn];
    _backBtn.frame=CGRectMake(10, 20, 70, 30);
    [_backBtn addTarget:self action:@selector(goToBack) forControlEvents:UIControlEventTouchUpInside];
    

    
}


-(void)layOutConstraints{
    
    [_rechargeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.mas_top).offset(20);
        make.height.mas_equalTo(35);
    }];
    
    [_moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.mas_top).offset(70);
        make.height.mas_equalTo(30);
    }];
    
    [_balanceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(_moneyLab.mas_bottom).offset(5);
        make.height.mas_equalTo(15);
    }];
    
   
}

+(CGFloat)computeHeight:(id)info{
    return 164;
}

-(void)setDataSource:(id)dataSource{
    _dataSource=dataSource;
    _moneyLab.text = [MCMathUnits GetMoneyShowNum:dataSource];

    

}
//设置不同字体颜色
-(void)setTextColor:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text];
    //设置字号
    [str addAttribute:NSFontAttributeName value:font range:range];
    //设置文字颜色
    [str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];
    label.attributedText = str;
}

-(void)goToBack{
    [[UIView MCcurrentViewController].navigationController popViewControllerAnimated:YES];
}

@end




























